<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>伏特加 平台</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link
      href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css"
      rel="stylesheet"
    />
    <script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.8/dist/chart.umd.min.js"></script>
    <link
      href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap"
      rel="stylesheet"
    />

    <!-- Tailwind 配置 -->
    <script>
      tailwind.config = {
        theme: {
          extend: {
            colors: {
              primary: "#165DFF",
              secondary: "#36CFC9",
              accent: "#722ED1",
              dark: "#1D2129",
              "gray-light": "#F2F3F5",
              "gray-medium": "#C9CDD4",
              "gray-dark": "#86909C",
            },
            fontFamily: {
              inter: ["Inter", "sans-serif"],
            },
          },
        },
      };
    </script>

    <style type="text/tailwindcss">
      @layer utilities {
        .content-auto {
          content-visibility: auto;
        }
        .sidebar-item-active {
          @apply bg-primary/10 text-primary border-l-4 border-primary;
        }
        .card-hover {
          @apply transition-all duration-300 hover:shadow-lg hover:-translate-y-1;
        }
        .btn-primary {
          @apply bg-primary text-white px-4 py-2 rounded-lg hover:bg-primary/90 transition-all;
        }
        .btn-secondary {
          @apply bg-white text-primary border border-primary px-4 py-2 rounded-lg hover:bg-primary/5 transition-all;
        }
      }
    </style>
  </head>
  <body class="font-inter bg-gray-light min-h-screen flex flex-col">
    <!-- 顶部导航栏 -->
    <header class="bg-white shadow-sm">
      <div
        class="container mx-auto px-4 py-3 flex justify-between items-center"
      >
        <div class="flex items-center space-x-2">
          <i class="fa fa-robot text-primary text-2xl"></i>
          <h1 class="text-xl font-bold text-dark">伏特加 平台</h1>
        </div>
        <div class="flex items-center space-x-4">
          <div class="relative">
            <input
              type="text"
              placeholder="搜索..."
              class="pl-10 pr-4 py-2 rounded-lg border border-gray-medium focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary transition-all"
            />
            <i
              class="fa fa-search absolute left-3 top-1/2 -translate-y-1/2 text-gray-dark"
            ></i>
          </div>
          <div class="flex items-center space-x-2">
            <img
              src="https://picsum.photos/id/1005/200/200"
              alt="用户头像"
              class="w-8 h-8 rounded-full object-cover"
            />
            <span class="hidden md:inline-block text-sm font-medium"
              >管理员</span
            >
          </div>
        </div>
      </div>
    </header>

    <div class="flex flex-1 overflow-hidden">
      <!-- 左侧导航栏 -->
      <aside
        id="sidebar"
        class="w-64 bg-white shadow-sm h-[calc(100vh-64px)] fixed left-0 overflow-y-auto transition-all duration-300 ease-in-out transform z-10"
      >
        <nav class="py-4">
          <div class="px-4 mb-4">
            <h2
              class="text-xs font-semibold text-gray-dark uppercase tracking-wider"
            >
              主导航
            </h2>
          </div>

          <a
            href="#dashboard"
            class="flex items-center px-4 py-3 sidebar-item-active"
          >
            <i class="fa fa-home w-6"></i>
            <span class="ml-2">首页</span>
          </a>

          <div class="nav-group">
            <div
              class="flex items-center justify-between px-4 py-3 hover:bg-gray-light cursor-pointer group-toggle"
            >
              <div class="flex items-center">
                <i class="fa fa-cogs w-6"></i>
                <span class="ml-2">模型处理</span>
              </div>
              <i
                class="fa fa-chevron-down text-xs transition-transform duration-300 group-toggle-icon"
              ></i>
            </div>

            <div class="nav-submenu pl-10 py-2 hidden">
              <a
                href="{{ url_for('trans') }}"
                class="block px-4 py-2 text-sm hover:bg-gray-light rounded"
                >模型训练</a
              >
              <a
                href="{{ url_for('ceshi') }}"
                class="block px-4 py-2 text-sm hover:bg-gray-light rounded"
                >模型测试</a
              >
              <a
                href="#model-evaluation"
                class="block px-4 py-2 text-sm hover:bg-gray-light rounded"
                >模型评估</a
              >
            </div>
          </div>

          <a
            href="{{ url_for('shujuji') }}"
            class="flex items-center px-4 py-3 hover:bg-gray-light"
          >
            <i class="fa fa-database w-6"></i>
            <span class="ml-2">数据集</span>
          </a>

          <a
            href="#model-analysis"
            class="flex items-center px-4 py-3 hover:bg-gray-light"
          >
            <i class="fa fa-bar-chart w-6"></i>
            <span class="ml-2">模型分析</span>
          </a>

          <a
            href="http://10.136.20.125:3000/"
            class="flex items-center px-4 py-3 hover:bg-gray-light"
          >
            <i class="fa fa-comments w-6"></i>
            <span class="ml-2">AI 对话</span>
          </a>

          <div class="px-4 pt-6 pb-2 mt-6 border-t border-gray-light">
            <h2
              class="text-xs font-semibold text-gray-dark uppercase tracking-wider"
            >
              设置
            </h2>
          </div>

          <a
            href="#settings"
            class="flex items-center px-4 py-3 hover:bg-gray-light"
          >
            <i class="fa fa-cog w-6"></i>
            <span class="ml-2">系统设置</span>
          </a>

          <a
            href="#help"
            class="flex items-center px-4 py-3 hover:bg-gray-light"
          >
            <i class="fa fa-question-circle w-6"></i>
            <span class="ml-2">帮助中心</span>
          </a>
        </nav>
      </aside>

      <!-- 主内容区 -->
      <main class="flex-1 ml-64 p-6 transition-all duration-300">
        <!-- 页面标题 -->
        <div class="mb-6">
          <h1 class="text-[clamp(1.5rem,3vw,2.5rem)] font-bold text-dark">
            首页
          </h1>
          <p class="text-gray-dark mt-1">
            欢迎使用 伏特加 平台，这里可以管理和监控你的 AI 模型
          </p>
        </div>

        <!-- 统计卡片 -->
        <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8">
          <div class="bg-white rounded-xl shadow-sm p-6 card-hover">
            <div class="flex items-center justify-between">
              <div>
                <p class="text-gray-dark text-sm">模型总数</p>
                <h3 class="text-3xl font-bold mt-1">24</h3>
                <p class="text-green-500 text-xs mt-2 flex items-center">
                  <i class="fa fa-arrow-up mr-1"></i> 较上周增长 12%
                </p>
              </div>
              <div
                class="w-12 h-12 rounded-lg bg-primary/10 flex items-center justify-center"
              >
                <i class="fa fa-cube text-primary text-xl"></i>
              </div>
            </div>
          </div>

          <div class="bg-white rounded-xl shadow-sm p-6 card-hover">
            <div class="flex items-center justify-between">
              <div>
                <p class="text-gray-dark text-sm">运行中任务</p>
                <h3 class="text-3xl font-bold mt-1">7</h3>
                <p class="text-green-500 text-xs mt-2 flex items-center">
                  <i class="fa fa-arrow-up mr-1"></i> 较上周增长 5%
                </p>
              </div>
              <div
                class="w-12 h-12 rounded-lg bg-secondary/10 flex items-center justify-center"
              >
                <i class="fa fa-spinner text-secondary text-xl"></i>
              </div>
            </div>
          </div>

          <div class="bg-white rounded-xl shadow-sm p-6 card-hover">
            <div class="flex items-center justify-between">
              <div>
                <p class="text-gray-dark text-sm">数据集</p>
                <h3 class="text-3xl font-bold mt-1">14</h3>
                <p class="text-red-500 text-xs mt-2 flex items-center">
                  <i class="fa fa-arrow-down mr-1"></i> 较上周减少 3%
                </p>
              </div>
              <div
                class="w-12 h-12 rounded-lg bg-accent/10 flex items-center justify-center"
              >
                <i class="fa fa-database text-accent text-xl"></i>
              </div>
            </div>
          </div>

          <div class="bg-white rounded-xl shadow-sm p-6 card-hover">
            <div class="flex items-center justify-between">
              <div>
                <p class="text-gray-dark text-sm">API 调用</p>
                <h3 class="text-3xl font-bold mt-1">12,548</h3>
                <p class="text-green-500 text-xs mt-2 flex items-center">
                  <i class="fa fa-arrow-up mr-1"></i> 较上周增长 28%
                </p>
              </div>
              <div
                class="w-12 h-12 rounded-lg bg-orange-100 flex items-center justify-center"
              >
                <i class="fa fa-bolt text-orange-500 text-xl"></i>
              </div>
            </div>
          </div>
        </div>

        <!-- 模型训练状态 -->
        <div class="grid grid-cols-1 lg:grid-cols-3 gap-6 mb-8">
          <div class="bg-white rounded-xl shadow-sm p-6 lg:col-span-2">
            <div class="flex justify-between items-center mb-6">
              <h2 class="text-lg font-semibold">模型训练状态</h2>
              <div class="flex space-x-2">
                <button class="btn-secondary text-sm">周</button>
                <button
                  class="bg-primary/10 text-primary px-4 py-2 rounded-lg text-sm"
                >
                  月
                </button>
                <button class="btn-secondary text-sm">年</button>
              </div>
            </div>
            <div class="h-64">
              <canvas id="trainingChart"></canvas>
            </div>
          </div>

          <div class="bg-white rounded-xl shadow-sm p-6">
            <div class="flex justify-between items-center mb-6">
              <h2 class="text-lg font-semibold">模型性能</h2>
              <a href="#" class="text-primary text-sm hover:underline"
                >查看全部</a
              >
            </div>
            <div class="space-y-4">
              <div>
                <div class="flex justify-between text-sm mb-1">
                  <span>图像分类模型</span>
                  <span>92.5%</span>
                </div>
                <div class="w-full bg-gray-200 rounded-full h-2">
                  <div
                    class="bg-primary h-2 rounded-full"
                    style="width: 92.5%"
                  ></div>
                </div>
              </div>
              <div>
                <div class="flex justify-between text-sm mb-1">
                  <span>目标检测模型</span>
                  <span>87.3%</span>
                </div>
                <div class="w-full bg-gray-200 rounded-full h-2">
                  <div
                    class="bg-secondary h-2 rounded-full"
                    style="width: 87.3%"
                  ></div>
                </div>
              </div>
              <div>
                <div class="flex justify-between text-sm mb-1">
                  <span>NLP 情感分析</span>
                  <span>89.1%</span>
                </div>
                <div class="w-full bg-gray-200 rounded-full h-2">
                  <div
                    class="bg-accent h-2 rounded-full"
                    style="width: 89.1%"
                  ></div>
                </div>
              </div>
              <div>
                <div class="flex justify-between text-sm mb-1">
                  <span>推荐系统</span>
                  <span>78.4%</span>
                </div>
                <div class="w-full bg-gray-200 rounded-full h-2">
                  <div
                    class="bg-orange-500 h-2 rounded-full"
                    style="width: 78.4%"
                  ></div>
                </div>
              </div>
              <div>
                <div class="flex justify-between text-sm mb-1">
                  <span>语音识别</span>
                  <span>94.2%</span>
                </div>
                <div class="w-full bg-gray-200 rounded-full h-2">
                  <div
                    class="bg-green-500 h-2 rounded-full"
                    style="width: 94.2%"
                  ></div>
                </div>
              </div>
            </div>
          </div>
        </div>

        <!-- 最近任务 -->
        <div class="bg-white rounded-xl shadow-sm p-6 mb-8">
          <div class="flex justify-between items-center mb-6">
            <h2 class="text-lg font-semibold">最近任务</h2>
            <button class="btn-primary text-sm">
              <i class="fa fa-plus mr-1"></i> 新建任务
            </button>
          </div>
          <div class="overflow-x-auto">
            <table class="min-w-full divide-y divide-gray-200">
              <thead>
                <tr>
                  <th
                    class="px-6 py-3 text-left text-xs font-medium text-gray-dark uppercase tracking-wider"
                  >
                    任务名称
                  </th>
                  <th
                    class="px-6 py-3 text-left text-xs font-medium text-gray-dark uppercase tracking-wider"
                  >
                    状态
                  </th>
                  <th
                    class="px-6 py-3 text-left text-xs font-medium text-gray-dark uppercase tracking-wider"
                  >
                    进度
                  </th>
                  <th
                    class="px-6 py-3 text-left text-xs font-medium text-gray-dark uppercase tracking-wider"
                  >
                    开始时间
                  </th>
                  <th
                    class="px-6 py-3 text-left text-xs font-medium text-gray-dark uppercase tracking-wider"
                  >
                    操作
                  </th>
                </tr>
              </thead>
              <tbody class="bg-white divide-y divide-gray-200">
                <tr>
                  <td class="px-6 py-4 whitespace-nowrap">
                    <div class="flex items-center">
                      <div
                        class="flex-shrink-0 h-8 w-8 bg-primary/10 rounded-lg flex items-center justify-center"
                      >
                        <i class="fa fa-cube text-primary"></i>
                      </div>
                      <div class="ml-4">
                        <div class="text-sm font-medium text-dark">
                          图像分类模型训练
                        </div>
                        <div class="text-xs text-gray-dark">CNN - ResNet50</div>
                      </div>
                    </div>
                  </td>
                  <td class="px-6 py-4 whitespace-nowrap">
                    <span
                      class="px-2 py-1 text-xs font-medium bg-green-100 text-green-800 rounded-full"
                    >
                      运行中
                    </span>
                  </td>
                  <td class="px-6 py-4 whitespace-nowrap">
                    <div class="w-full bg-gray-200 rounded-full h-2">
                      <div
                        class="bg-green-500 h-2 rounded-full"
                        style="width: 75%"
                      ></div>
                    </div>
                    <div class="text-xs text-gray-dark mt-1">75%</div>
                  </td>
                  <td
                    class="px-6 py-4 whitespace-nowrap text-sm text-gray-dark"
                  >
                    2025-07-10 09:30
                  </td>
                  <td class="px-6 py-4 whitespace-nowrap text-sm text-primary">
                    <a href="#" class="hover:underline">查看详情</a>
                  </td>
                </tr>
                <tr>
                  <td class="px-6 py-4 whitespace-nowrap">
                    <div class="flex items-center">
                      <div
                        class="flex-shrink-0 h-8 w-8 bg-secondary/10 rounded-lg flex items-center justify-center"
                      >
                        <i class="fa fa-database text-secondary"></i>
                      </div>
                      <div class="ml-4">
                        <div class="text-sm font-medium text-dark">
                          数据集预处理
                        </div>
                        <div class="text-xs text-gray-dark">图像增强与标注</div>
                      </div>
                    </div>
                  </td>
                  <td class="px-6 py-4 whitespace-nowrap">
                    <span
                      class="px-2 py-1 text-xs font-medium bg-blue-100 text-blue-800 rounded-full"
                    >
                      已完成
                    </span>
                  </td>
                  <td class="px-6 py-4 whitespace-nowrap">
                    <div class="w-full bg-gray-200 rounded-full h-2">
                      <div
                        class="bg-blue-500 h-2 rounded-full"
                        style="width: 100%"
                      ></div>
                    </div>
                    <div class="text-xs text-gray-dark mt-1">100%</div>
                  </td>
                  <td
                    class="px-6 py-4 whitespace-nowrap text-sm text-gray-dark"
                  >
                    2025-07-09 14:15
                  </td>
                  <td class="px-6 py-4 whitespace-nowrap text-sm text-primary">
                    <a href="#" class="hover:underline">查看详情</a>
                  </td>
                </tr>
                <tr>
                  <td class="px-6 py-4 whitespace-nowrap">
                    <div class="flex items-center">
                      <div
                        class="flex-shrink-0 h-8 w-8 bg-accent/10 rounded-lg flex items-center justify-center"
                      >
                        <i class="fa fa-bar-chart text-accent"></i>
                      </div>
                      <div class="ml-4">
                        <div class="text-sm font-medium text-dark">
                          模型评估报告
                        </div>
                        <div class="text-xs text-gray-dark">目标检测模型</div>
                      </div>
                    </div>
                  </td>
                  <td class="px-6 py-4 whitespace-nowrap">
                    <span
                      class="px-2 py-1 text-xs font-medium bg-yellow-100 text-yellow-800 rounded-full"
                    >
                      待处理
                    </span>
                  </td>
                  <td class="px-6 py-4 whitespace-nowrap">
                    <div class="w-full bg-gray-200 rounded-full h-2">
                      <div
                        class="bg-yellow-500 h-2 rounded-full"
                        style="width: 0%"
                      ></div>
                    </div>
                    <div class="text-xs text-gray-dark mt-1">0%</div>
                  </td>
                  <td
                    class="px-6 py-4 whitespace-nowrap text-sm text-gray-dark"
                  >
                    2025-07-11 16:45
                  </td>
                  <td class="px-6 py-4 whitespace-nowrap text-sm text-primary">
                    <a href="#" class="hover:underline">查看详情</a>
                  </td>
                </tr>
                <tr>
                  <td class="px-6 py-4 whitespace-nowrap">
                    <div class="flex items-center">
                      <div
                        class="flex-shrink-0 h-8 w-8 bg-red-100 rounded-lg flex items-center justify-center"
                      >
                        <i class="fa fa-exclamation-triangle text-red-500"></i>
                      </div>
                      <div class="ml-4">
                        <div class="text-sm font-medium text-dark">
                          NLP 模型训练
                        </div>
                        <div class="text-xs text-gray-dark">
                          BERT - 情感分析
                        </div>
                      </div>
                    </div>
                  </td>
                  <td class="px-6 py-4 whitespace-nowrap">
                    <span
                      class="px-2 py-1 text-xs font-medium bg-red-100 text-red-800 rounded-full"
                    >
                      失败
                    </span>
                  </td>
                  <td class="px-6 py-4 whitespace-nowrap">
                    <div class="w-full bg-gray-200 rounded-full h-2">
                      <div
                        class="bg-red-500 h-2 rounded-full"
                        style="width: 30%"
                      ></div>
                    </div>
                    <div class="text-xs text-gray-dark mt-1">30%</div>
                  </td>
                  <td
                    class="px-6 py-4 whitespace-nowrap text-sm text-gray-dark"
                  >
                    2025-07-08 11:20
                  </td>
                  <td class="px-6 py-4 whitespace-nowrap text-sm text-primary">
                    <a href="#" class="hover:underline">查看详情</a>
                  </td>
                </tr>
              </tbody>
            </table>
          </div>
        </div>
      </main>
    </div>

    <script>
      // 导航菜单折叠功能
      document.addEventListener("DOMContentLoaded", function () {
        const groupToggle = document.querySelector(".group-toggle");
        const submenu = document.querySelector(".nav-submenu");
        const toggleIcon = document.querySelector(".group-toggle-icon");

        if (groupToggle && submenu && toggleIcon) {
          groupToggle.addEventListener("click", function () {
            submenu.classList.toggle("hidden");
            toggleIcon.classList.toggle("rotate-180");
          });
        }

        // 初始化图表
        const ctx = document.getElementById("trainingChart");
        if (ctx) {
          new Chart(ctx, {
            type: "line",
            data: {
              labels: ["1月", "2月", "3月", "4月", "5月", "6月", "7月"],
              datasets: [
                {
                  label: "模型训练数量",
                  data: [6, 8, 12, 9, 15, 18, 24],
                  borderColor: "#165DFF",
                  backgroundColor: "rgba(22, 93, 255, 0.1)",
                  tension: 0.4,
                  fill: true,
                },
                {
                  label: "API 调用次数 (千)",
                  data: [4.2, 5.1, 6.8, 7.5, 9.3, 11.2, 12.5],
                  borderColor: "#36CFC9",
                  backgroundColor: "rgba(54, 207, 201, 0.1)",
                  tension: 0.4,
                  fill: true,
                },
              ],
            },
            options: {
              responsive: true,
              maintainAspectRatio: false,
              plugins: {
                legend: {
                  position: "top",
                },
              },
              scales: {
                y: {
                  beginAtZero: true,
                },
              },
            },
          });
        }

        // 移动端侧边栏切换
        const sidebarToggle = document.getElementById("sidebarToggle");
        const sidebar = document.getElementById("sidebar");
        const mainContent = document.querySelector("main");

        if (sidebarToggle) {
          sidebarToggle.addEventListener("click", function () {
            sidebar.classList.toggle("-translate-x-full");
            if (window.innerWidth < 1024) {
              mainContent.classList.toggle("ml-0");
              mainContent.classList.toggle("ml-64");
            }
          });
        }

        // 监听窗口大小变化，调整侧边栏
        window.addEventListener("resize", function () {
          if (window.innerWidth >= 1024) {
            sidebar.classList.remove("-translate-x-full");
            mainContent.classList.remove("ml-0");
            mainContent.classList.add("ml-64");
          } else if (!sidebar.classList.contains("sidebar-open")) {
            sidebar.classList.add("-translate-x-full");
            mainContent.classList.remove("ml-64");
            mainContent.classList.add("ml-0");
          }
        });
      });
    </script>
  </body>
</html>
